<template>
  <div class="header">
    <header>
      <van-nav-bar
      :title="name"
      fixed
      @click-left="goBack">
        <template #left>
          <div v-if="!noback">
            <van-icon name="arrow-left" size="20" color="#000" />
          </div>
        </template>
        <template #right>
            <van-icon name="ellipsis" size="24" color="#000" />
        </template>
      </van-nav-bar>
    </header>
    <div class="block" />
  </div>
</template>

<script>
export default {
  name: 'sHeader',
  props: {
    name: {
      type: String,
      default: ''
    },
    back: {
      type: String,
      default: ''
    },
    noback: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    goBack() {
      if (!this.back) {
        this.$router.go(-1)
      } else {
        this.$router.push({ path: this.back })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .header {
    .block {
      height: 45px;
    }
  }
</style>